package com.ls.dbpool;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

public class JsonTest {
	public static void main(String[] args) throws Exception {
		/*System.out.println(String.format("saa%02d", 13));
		ClassLoader l = new URLClassLoader(new URL[] { new File("d:\\temp\\cc\\aa.jar").toURL() });
		Class c = l.loadClass("Test");
		System.out.println(c.newInstance());*/
		test();
	}

	private static void test() throws MalformedURLException, ClassNotFoundException, InstantiationException, IllegalAccessException, SQLException {
		ClassLoader l = new URLClassLoader(new URL[] { new File("d:\\temp\\cc\\postgresql-9.0-801.jdbc4.jar").toURL() });
		Class s= Class.forName("org.postgresql.Driver",true,l);
		Driver driver;
		driver = (Driver)s.newInstance();
		
		Properties prop = new Properties();
		prop.setProperty("user", "soma");
		prop.setProperty("password", "soma");
		String url = "jdbc:postgresql://20.12.16.219:5432/soma";
		Connection con;
		con = driver.connect(url, prop);
		Statement  stat = con.createStatement();
		ResultSet rs = stat.executeQuery("select count(*) from cc_log_app_nc_msql_2");
		while(rs.next()){
			System.out.println(rs.getString(1));
		}
		con.close();
		
	}
}
